//==============================================================================
// Stopwatch 
//==============================================================================

#include "stdafx.h"
#include "../Stopwatch.h"

namespace LNote
{
namespace Core
{
namespace System
{

//==============================================================================
// Stopwatch
//==============================================================================

	//----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	Stopwatch::Stopwatch()
	{
		memset(&mFreq, 0x00, sizeof(mFreq));
		memset(&mBefore, 0x00, sizeof(mBefore));
	}

	//----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	Stopwatch::~Stopwatch()
	{
	}

	//----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	void Stopwatch::start()
	{
		::QueryPerformanceFrequency(&mFreq);
		::QueryPerformanceCounter(&mBefore);
	}

	//----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	lnU64 Stopwatch::getElapsedTime()
	{
		LARGE_INTEGER counter;
		::QueryPerformanceCounter(&counter);
		return (lnU64)((counter.QuadPart - mBefore.QuadPart) * (1000 * 1000 * 1000) / mFreq.QuadPart);
	}

} // namespace System
} // namespace Core
} // namespace LNote
